import thrift.protocol.TBinaryProtocol as TBinaryProtocol
import thrift.transport.THttpClient as THttpClient
import evernote.edam.userstore.UserStore as UserStore
from cnconst import CNConst


class CNAuth:
	
	def authenticate(self,user,passwd):
		userStoreHttpClient = THttpClient.THttpClient(CNConst.userStoreUri)
		userStoreProtocol = TBinaryProtocol.TBinaryProtocol(userStoreHttpClient)
		userStore = UserStore.Client(userStoreProtocol);
		authResult = userStore.authenticate(user, passwd,
                                    CNConst.consumerKey, CNConst.consumerSecret)
		self.user = authResult.user
		self.authToken = authResult.authenticationToken
		self.noteStoreUri =  CNConst.noteStoreUriBase + self.user.shardId
		
		
		
		